//
//  AMAlertView.m
//  WeiDu_1_0
//
//  Created by foguo-mac-1 on 01/07/16.
//  Copyright (c) 2016 WeiDu Energy Tech. All rights reserved.
//

#import "HOAlertView.h"
#import "HOUtils.h"
#import "HOUIMgr.h"
static NSMutableArray *alertList;
static HOAlertView *_instance;
@implementation HOAlertView
@synthesize data;
@synthesize inputBox;
@synthesize isStartTime;
@synthesize datePicker;

//- (void)willPresentAlertView:(UIAlertView*)alertView{
//    if(alertView.tag == 0){
//        for(UIView *subView in alertView.subviews){
//            if([subView isKindOfClass:[UIButton class]]){
//                UIButton *button = (UIButton *)subView;
//                button.titleLabel.textColor = [UIColor blackColor];
//            }else if([subView isKindOfClass:[UITextField class]]){
//                UITextField *textView = (UITextField *)subView;
//                textView.font = [UIFont fontWithName:@"Helvetica" size:30.0f];
//            }
//        }
//    }
//}

+ (HOAlertView *)sharedInstance
{
	if(_instance)
	{
		_instance = [[HOAlertView alloc] init];
	}
	return _instance;
}

- (void)cleanup
{
	[self createAlertList];
	[alertList removeAllObjects];
}

- (void)createAlertList
{
	if(!alertList)
	{
		alertList = [[NSMutableArray alloc] init];
	}
}

- (BOOL)isPopedUpBeforeWithTag:(NSString *)tag
{
	[self createAlertList];
	return [alertList containsObject:tag];
}

- (void)removeAlertWithTag:(NSString *)tag
{
	[self createAlertList];
	[alertList removeObject:tag];
}

- (void)addAlertWithTag:(NSString *)tag
{
	[self createAlertList];
	if([alertList containsObject:tag])
		return;
	[alertList addObject:tag];
}

- (void)show
{
	[self createAlertList];
	if([self isPopedUpBeforeWithTag:[NSString stringWithFormat:@"%d", (int)self.tag]])
	{
		return;
	}
	
	[self addAlertWithTag:[NSString stringWithFormat:@"%d", (int)self.tag]];
	[super show];
}

- (void)alertDidClose
{
	[self createAlertList];
	[self removeAlertWithTag:[NSString stringWithFormat:@"%d", (int)self.tag]];
}

- (void)dealloc
{
    self.data = nil;
    
    [super dealloc];
}
@end
